<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta name="format-detection" content="telephone=no">
	<meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css" type="text/css" />
	<link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css" />
	<script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
	<title>老杜生物科技</title>
</head>
<body>
	<div class="html login">
		<div class="cont center">
			<form id="signupForm">
			<p class="lgtil">会员登录</p>
			<p class="lgline"><img src="/assets/images/icon_name.png" class="lgico"><input type="text" name="username" id="J_name" class="J_ctrol ctrol" data-target="username" placeholder="用户名"></p>
			<p class="lgline"><img src="/assets/images/icon_pwd.png" class="lgico"><input type="password" name="password" id="J_pwd" class="J_ctrol ctrol" data-target="password" placeholder="登录密码"></p>
			<!--
			<p class="lgline"><img src="/assets/images/icon_yzm.png" class="lgico"><input type="password" name="" id="J_yzm" class="J_ctrol ctrol" data-target="yzm" placeholder="验证码"><img src="img/yzm.jpg" class="yzm"></p>
			 -->
			<p class="lgbtn"><button class="btn btn_lg btn_rd30" id="J_btn">登录</button></p>
			<a href="forgetPassword" class="lgfor">忘记密码？</a>
			</form>
			<div style="    position: absolute;left: 43px;bottom: 40px;color: #999;">
				<a href="http://www.beian.miit.gov.cn">Copyright © 2020 老杜生物科技(上海)有限公司 | ICP证: 沪ICP备16041106号-2</a>
			</div>
		</div>

	</div>
	<script th:inline="javascript"> var ctx = [[@{/}]] ; </script>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="/js/bootstrap.min.js?v=3.3.6" th:src="@{/js/bootstrap.min.js?v=3.3.6}"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0" th:src="@{/js/content.js?v=1.0.0}"></script>

<!-- jQuery Validation plugin javascript-->
<script src="/js/plugins/validate/jquery.validate.min.js" th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="/js/plugins/validate/messages_zh.min.js" th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">
    $(document).ready(function () {

        console.log(ctx);
        validateRule();

    });

    $.validator.setDefaults({
        submitHandler: function () {
            login();
        }
    });

    function login() {
        $.ajax({
            type: "POST",
            url: ctx+"login",
            data: $('#signupForm').serialize(),
            success: function (r) {
                if (r.code == 0) {
                    if(r.user.type==1){
                        parent.location.href = '/admin';
                    }else{
                        parent.location.href = '/';
                    }
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名",
                },
                password: {
                    required: icon + "请输入您的密码",
                }
            }
        })
    }
</script>
</body>
</html>
